/** */
package com.hotau.account;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.hotau.HotauActivity;
import com.hotau.R;
import com.hotau.member.service.MemberService;
import com.hotau.util.DialogUtil;
import com.hotau.util.ValidateUtils;

/**
 * 密码管理
 * 
 * @author fengweili</br> 1.0
 * @author liujia (liujia9234@126.com)1.1 2011-12-9 下午02:39:51
 * @version 1.1
 *          <ul>
 *          <li>1.0 创建</li>
 *          <li>1.1 实现具体的功能</li>
 *          </ul>
 */
public class PasswordManageFragment extends Fragment implements OnClickListener {

	private Button password_manager_btn_edit_loginpwd = null;
	private Button password_manager_btn_edit_paypwd = null;
	private Button password_manager_btn_find_paypwd = null;

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		initAllWidget();
		initAllEvent();
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		return inflater.inflate(R.layout.account_password_manage, container,
				false);
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		HotauActivity csmbpActivity = (HotauActivity) getActivity();
		switch (v.getId()) {
		case R.id.account_password_manager_btn_edit_loginpwd:
			Bundle pb = new Bundle();
			pb.putBoolean("isPayPwd", false);
			PasswordEditFragment pef = new PasswordEditFragment();
			pef.setArguments(pb);
			csmbpActivity.pushFragment("修改登录密码", pef);
			break;
		case R.id.account_password_manager_btn_edit_paypwd:
			Bundle pb1 = new Bundle();
			pb1.putBoolean("isPayPwd", false);
			PasswordEditFragment pef1 = new PasswordEditFragment();
			pef1.setArguments(pb1);
			csmbpActivity.pushFragment("修改支付密码", pef1);
			break;
		case R.id.account_password_manager_btn_find_paypwd:
			if (ValidateUtils.isEmail(MemberService.getUserCode(getActivity()))) {
				DialogUtil.showDialog(getActivity(), "提示",
						"email账号请登陆网页版新生支付平台进行修改支付密码操作");
			} else {
				csmbpActivity
						.pushFragment("找回支付密码", new FindPasswordFragment());
			}
			break;
		default:
			break;
		}
	}

	/**
	 * 初始化所有控件
	 */
	public void initAllWidget() {
		password_manager_btn_edit_loginpwd = (Button) getActivity()
				.findViewById(R.id.account_password_manager_btn_edit_loginpwd);
		password_manager_btn_edit_paypwd = (Button) getActivity().findViewById(
				R.id.account_password_manager_btn_edit_paypwd);
		password_manager_btn_find_paypwd = (Button) getActivity().findViewById(
				R.id.account_password_manager_btn_find_paypwd);
	}

	/**
	 * 初始化所有事件
	 */
	public void initAllEvent() {
		password_manager_btn_edit_loginpwd.setOnClickListener(this);
		password_manager_btn_edit_paypwd.setOnClickListener(this);
		password_manager_btn_find_paypwd.setOnClickListener(this);
	}

}
